/*
 * multicall_asynch.h
 *
 *  Created on: Apr 7, 2012
 *      Author: albert
 */

#ifndef MULTICALL_ASYNCH_H_
#define MULTICALL_ASYNCH_H_

void
xmlrpc_client_start_multirpc(xmlrpc_env *             const envP,
                        struct xmlrpc_client *   const clientP,
                        xmlrpc_server_info *     const serverInfoP[],
                        int numServer,
                        const char *             const methodName,
                        xmlrpc_value *           const argP,
                        xmlrpc_response_handler        completionFn,
                        void *                   const userData);

void
wait_multiloop_finish();

void
multiAsynchComplete(struct xmlrpc_call_info * const callInfoP,
               xmlrpc_mem_block *        const responseXmlP,
               xmlrpc_env                const transportEnv);

//void
//xmlrpc_client_multicall_asynch_params_server(
//    xmlrpc_server_info * const serverInfoP[],
//    int numServer,
//    const char *         const methodName,
//    xmlrpc_response_handler    responseHandler,
//    void *               const userData,
//    xmlrpc_value *       const paramArrayP);

//void xmlrpc_client_multicall_server_asynch(xmlrpc_server_info * const serverInfoP[], int numServer,
//		const char * const methodName, xmlrpc_response_handler responseHandler,
//		void * const userData, const char * const format, ...);

void xmlrpc_client_multicall_asynch_params(const char * const serverUrls[],
		int numServer, const char * const methodName,
		xmlrpc_response_handler responseHandler, void * const userData,
		xmlrpc_value * const paramArrayP);

void xmlrpc_client_start_multirpc(xmlrpc_env * const envP,
		struct xmlrpc_client * const clientP,
		xmlrpc_server_info * const serverInfoP[], int numServer,
		const char * const methodName, xmlrpc_value * const argP,
		xmlrpc_response_handler completionFn, void * const userData);

struct xmlrpc_call_info {
    /* This is all the information needed to finish executing a started
       RPC.

       You don't need this for an RPC the user executes synchronously,
       because then you can just use the storage in which the user passed
       his arguments.  But for asynchronous, the user will take back his
       storage, and we need to keep this info in our own.
    */

    struct {
        /* This are arguments to pass to the completion function.  It
           doesn't make sense to use them for anything else.  In fact, it
           really doesn't make sense for them to be arguments to the
           completion function, but they are historically.  */
        const char *   serverUrl;
        const char *   methodName;
        xmlrpc_value * paramArrayP;
        void *         userData;
    } completionArgs;
    xmlrpc_response_handler completionFn;


    /* The serialized XML data passed to this call. We keep this around
    ** for use by our source_anchor field. */
    xmlrpc_mem_block *serialized_xml;
};

struct xmlrpc_client {
/*----------------------------------------------------------------------------
   This represents a client object.
-----------------------------------------------------------------------------*/
    bool myTransport;
        /* The transport described below was created by this object;
           No one else knows it exists and this object is responsible
           for destroying it.
        */
    struct xmlrpc_client_transport *   transportP;
    struct xmlrpc_client_transport_ops transportOps;
    xmlrpc_dialect                     dialect;
};


#endif /* MULTICALL_ASYNCH_H_ */
